import request from '@/utils/request'

// 查询设备管理列表
export function listDevice(query) {
  return request({
    url: '/oil/device/list',
    method: 'get',
    params: query
  })
}

// 查询设备管理详细
export function getDevice(id) {
  return request({
    url: '/oil/device/' + id,
    method: 'get'
  })
}

// 查询设备管理详细
export function getDeviceByCode(code) {
  return request({
    url: '/oil/device/getByCode/' + code,
    method: 'get'
  })
}

// 新增设备管理
export function addDevice(data) {
  return request({
    url: '/oil/device',
    method: 'post',
    data: data
  })
}

// 修改设备管理
export function updateDevice(data) {
  return request({
    url: '/oil/device',
    method: 'put',
    data: data
  })
}

// 删除设备管理
export function delDevice(id) {
  return request({
    url: '/oil/device/' + id,
    method: 'delete'
  })
}

// 根据设备编号启动采集程序
export function startDriverByDevice(code) {
  return request({
    url: '/oil/sensorManage/sensor/startDriverByDevice/' + code,
    method: 'get'
  })
}

// 根据设备编号关闭采集程序
export function stopDriverByDevice(code) {
  return request({
    url: '/oil/sensorManage/sensor/stopDriverByDevice/' + code,
    method: 'get'
  })
}

// 根据设备编号查询采集状态
export function getConnectState(code) {
  return request({
    url: '/oil/sensorManage/sensor/connectState/' + code,
    method: 'get'
  })
}